/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.feignimpl.goods;


import com.enation.app.javashop.client.goods.GoodsClient;
import com.enation.app.javashop.core.client.fallback.goods.GoodsClientFallbackFactory;
import com.enation.app.javashop.core.handler.FeignConfiguration;
import com.enation.app.javashop.framework.database.WebPage;
import com.enation.app.javashop.model.goods.dos.CategoryDO;
import com.enation.app.javashop.model.goods.dos.GoodsDO;
import com.enation.app.javashop.model.goods.dto.GoodsQueryParam;
import com.enation.app.javashop.model.goods.vo.*;
import com.enation.app.javashop.model.security.ScanModuleDTO;
import com.enation.app.javashop.model.security.ScanResult;
import com.enation.app.javashop.model.trade.order.vo.OrderSkuVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author fk
 * @version v1.0
 * @Description: 微服务商品对外接口
 * @date 2018/7/30 15:03
 * @since v7.0.0
 */
@FeignClient(name = "goods-service", fallbackFactory = GoodsClientFallbackFactory.class,configuration = {FeignConfiguration.class})
public interface GoodsClientFeignImpl extends GoodsClient {

    @Override
    @RequestMapping(value = "/client/goods/count/param", method = RequestMethod.GET)
    Integer queryGoodsCountByParam(@RequestParam("status") Integer status, @RequestParam("seller_id") Long sellerId);

    /**
     * 获取新赠商品
     *
     * @param length
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/new", method = RequestMethod.GET)
    List<BackendGoodsVO> newGoods(@RequestParam("length") Integer length);

    /**
     * 下架某店铺的全部商品
     *
     * @param sellerId
     */
    @Override
    @RequestMapping(value = "/client/goods/under", method = RequestMethod.POST)
    void underShopGoods(@RequestParam("seller_id") Long sellerId);

    /**
     * 更新商品好平率
     */
    @Override
    @RequestMapping(value = "/client/goods/grade", method = RequestMethod.POST)
    void updateGoodsGrade();

    /**
     * 缓存中查询商品的信息
     *
     * @param goodsId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/{goods_id}", method = RequestMethod.GET)
    CacheGoods getFromCache(@PathVariable("goods_id") Long goodsId);

    /**
     * 查询多个商品的基本信息
     *
     * @param goodsIds
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/more/{goods_ids}", method = RequestMethod.GET)
    List<GoodsSelectLine> query(@PathVariable("goods_ids") Long[] goodsIds);

    /**
     * 判断商品是否都是某商家的商品
     *
     * @param goodsIds
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/seller/{goods_ids}/check", method = RequestMethod.GET)
    void checkSellerGoodsCount(@PathVariable("goods_ids") Long[] goodsIds);

    /**
     * 查询很多商品的信息和参数信息
     *
     * @param goodsIds
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/{goods_ids}/params", method = RequestMethod.GET)
    List<Map<String, Object>> getGoodsAndParams(@PathVariable("goods_ids") Long[] goodsIds);

    /**
     * 按销量查询若干条数据
     *
     * @param sellerId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/seller-goods", method = RequestMethod.GET)
    List<GoodsDO> listGoods(@RequestParam("seller_id") Long sellerId);

    /**
     * 缓存中查询sku信息
     *
     * @param skuId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/skus/{sku_id}", method = RequestMethod.GET)
    GoodsSkuVO getSkuFromCache(@PathVariable("sku_id") Long skuId);

    /**
     * 更新商品的评论数量
     *
     * @param goodsId
     * @param num
     */
    @Override
    @RequestMapping(value = "/client/goods/{goods_id}/comment-count", method = RequestMethod.POST)
    void updateCommentCount(@PathVariable("goods_id") Long goodsId, @RequestParam("num") Integer num);


    /**
     * 更新商品的购买数量
     *
     * @param list
     */
    @Override
    @RequestMapping(value = "/client/goods/buy-count", method = RequestMethod.POST)
    void updateBuyCount(@RequestBody List<OrderSkuVO> list);

    /**
     * 查询商品的总数量
     *
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/count", method = RequestMethod.GET)
    Integer queryGoodsCount();

    /**
     * 查询某范围的商品信息
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/{page_no}/{page_size}", method = RequestMethod.GET)
    List<Map<String,Object>> queryGoodsByRange(@PathVariable("page_no") Long pageNo, @PathVariable("page_size") Long pageSize);

    /**
     * 添加商品快照时使用的接口
     *
     * @param goodsId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/{goods_id}/snapshot", method = RequestMethod.GET)
    GoodsSnapshotVO queryGoodsSnapShotInfo(@PathVariable("goods_id") Long goodsId);

    /**
     * 查询商品列表
     *
     * @param goodsQueryParam
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods", method = RequestMethod.POST)
    WebPage list(@RequestBody GoodsQueryParam goodsQueryParam);

    /**
     * 校验商品模版是否使用
     *
     * @param templateId
     * @return 商品
     */
    @Override
    @RequestMapping(value = "/client/goods/template/{id}", method = RequestMethod.GET)
    GoodsDO checkShipTemplate(@PathVariable("id") Long templateId);

    /**
     * 查询某店铺正在售卖中的商品数量
     *
     * @param sellerId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/seller/{seller_id}", method = RequestMethod.GET)
    Integer getSellerGoodsCount(@PathVariable("seller_id") Long sellerId);


    /**
     * 修改某店铺商品店铺名称
     *
     * @param sellerId
     * @param sellerName
     */
    @Override
    @RequestMapping(value = "/client/goods/seller/{seller_id}/change-seller-name", method = RequestMethod.POST)
    void changeSellerName(@PathVariable("seller_id") Long sellerId, @RequestParam("seller_name") String sellerName);

    /**
     * 更新商品类型
     *
     * @param type 商品状态
     */
    @Override
    @RequestMapping(value = "/client/goods/seller/{seller_id}/change-goods-type", method = RequestMethod.POST)
    void updateGoodsType(@PathVariable("seller_id") Long sellerId, @RequestParam("type") String type);

    /**
     * 查询某店铺的积分商品
     *
     * @param shopId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/seller/{seller_id}/point-goods", method = RequestMethod.GET)
    List<GoodsDO> listPointGoods(@PathVariable("seller_id") Long shopId);

    /**
     * 查询多个sku的基本信息
     *
     * @param skuIds
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/skus/{sku_ids}/details", method = RequestMethod.GET)
    List<GoodsSelectLine> querySkus(@PathVariable("sku_ids") Long[] skuIds);

    @Override
    @RequestMapping(value = "/client/goods/{goods_ids}/goodsdos", method = RequestMethod.GET)
    List<GoodsDO> queryDo(@PathVariable("goods_ids") Long[] goodsIds);

    @Override
    @RequestMapping(value = "/client/goods/seller/{seller_id}/goods-details", method = RequestMethod.GET)
    List<Map<String, Object>> getGoodsAndParams(@PathVariable("seller_id") Long sellerId);

    @Override
    @RequestMapping(value = "/client/goods/category/{id}", method = RequestMethod.GET)
    CategoryDO getCategory(@PathVariable("id") Long id);

    @Override
    @RequestMapping(value = "/client/goods/{goods_ids}/info", method = RequestMethod.GET)
    List<Map<String, Object>> getGoods(@PathVariable("goods_ids") Long[] goodsIds);

    /**
     * 查询sku信息
     *
     * @param skuId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/sku/{sku_id}/db-info", method = RequestMethod.GET)
    GoodsSkuVO getSku(@PathVariable("sku_id") Long skuId);

    /**
     * 根据商品id查询所有sku
     *
     * @param goodsId 商品id
     * @return 所有sku
     */
    @Override
    @RequestMapping(value = "/client/goods/{goods_id}/sku-list", method = RequestMethod.GET)
    List<GoodsSkuVO> listByGoodsId(@PathVariable("goods_id") Long goodsId);

    /**
     * 根据商家id查询出所有的商品信息
     *
     * @param sellerId 商家id
     * @return 所有的商品信息
     */
    @Override
    @RequestMapping(value = "/client/goods/by-seller/{seller_id}", method = RequestMethod.GET)
    List<GoodsDO> getSellerGoods(@PathVariable("seller_id") Long sellerId);

    /**
     * 查询所有的分类，父子关系
     *
     * @param parentId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/category/{parent_id}/children", method = RequestMethod.GET)
    List<CategoryVO> listAllChildren(@PathVariable("parent_id") Long parentId);

    /**
     * 生成积分兑换商品的脚本信息
     *
     * @param skuId      商品skuID
     * @param exchangeId 积分兑换商品ID
     * @param price      兑换积分商品所需的价钱
     * @param point      兑换积分商品所需的积分
     */
    @Override
    @RequestMapping(value = "/client/goods/sku/{sku_id}/add-exchange-script", method = RequestMethod.POST)
    void createSkuExchangeScript(@PathVariable("sku_id") Long skuId, @RequestParam("exchange_id") Long exchangeId, @RequestParam("price") Double price, @RequestParam("point") Integer point);

    /**
     * 删除积分兑换商品的脚本信息
     *
     * @param skuId 商品skuID
     */
    @Override
    @RequestMapping(value = "/client/goods/sku/{sku_id}/del-exchange-script", method = RequestMethod.POST)
    void deleteSkuExchangeScript(@PathVariable("sku_id") Long skuId);

    /**
     * 更新商品是否是自营
     *
     * @param sellerId sellerId
     * @param selfOperated 是否是自营
     */
    @Override
    @RequestMapping(value = "/client/goods/goods-self-operated", method = RequestMethod.POST)
    void updateGoodsSelfOperated(@RequestParam("seller_id") Long sellerId,@RequestParam("self_operated") Integer selfOperated);

    /**
     * 查询未删除商品数量
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/count/page-create", method = RequestMethod.GET)
    Integer queryGoodsCountForPageCreate();

    /**
     * 查询SKU信息
     * @param skuId
     * @return
     */
    @Override
    @RequestMapping(value = "/client/goods/sku/{sku_id}/check-exist", method = RequestMethod.GET)
    Boolean checkExist(@PathVariable("sku_id") Long skuId);

    @Override
    @RequestMapping(value = "/client/goods/scan-module", method = RequestMethod.POST)
    ScanResult scanModule(@RequestBody ScanModuleDTO scanModuleDTO);

    @Override
    @RequestMapping(value = "/client/goods/sku/scan-module", method = RequestMethod.POST)
    ScanResult scanSkuModule(@RequestBody ScanModuleDTO scanModuleDTO);


    /**
     * 商品数据重新签名
     */
    @Override
    @RequestMapping(value = "/client/goods/resign", method = RequestMethod.GET)
    void reSign();


    /**
     * sku数据重新签名
     */
    @Override
    @RequestMapping(value = "/client/goods/sku/resign", method = RequestMethod.GET)
    void reSignSku();

    /**
     * 修复商品数据
     * @param goodsId
     */
    @Override
    @RequestMapping(value = "/client/goods/repair/{goods_id}", method = RequestMethod.GET)
    void repair(@PathVariable("goods_id")Long goodsId);

    /**
     * 修复sku数据
     * @param skuId
     */
    @Override
    @RequestMapping(value = "/client/goods/sku/repair/{sku_id}", method = RequestMethod.GET)
    void repairSku(@PathVariable("sku_id")Long skuId);
}
